<template>
	<view class="set_box">
		<input v-model="keyword" type="tel" placeholder="请输入联系电话" :maxlength="20" placeholder-style="color: #BBBBBB" />
		<view class="set_btn" @click="handleSave">保存联系电话</view>
	</view>
</template>

<script setup>
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import api from '../../common/api';
import { useUserinfoStore } from '@/stores/userInfo';
const userInfo_Store = useUserinfoStore();
const keyword = ref('')
onLoad((options) => {
	keyword.value = options.key
})

const handleSave = async () => {
	if (!keyword.value) {
		return uni.showToast({
			title: '请输入联系微信',
			icon: 'none'
		})
	}
	const res = await api.Updatemodifywechat_API({ keyword: keyword.value })
	if (res.code === 0) {
		uni.showToast({
			title: '修改成功',
			icon: 'none'
		})
		//获取用户信息
		await userInfo_Store.GetUserInfo();
		uni.navigateBack()
	}
}
</script>
<style lang="scss" scoped>
.set_box {
	border-top: 24rpx solid #f5f5f5;
	padding: 40rpx 24rpx 24rpx;

	input {
		padding: 0 20rpx;
		color: #333;
		font-size: 26rpx;
		box-sizing: border-box;
		height: 88rpx;
		background: #F6F6F6;
		border-radius: 8rpx;
		border: 2rpx solid #EEEEEE;
	}

	.set_btn {
		position: fixed;
		bottom: 24rpx;
		left: 24rpx;
		width: calc(100% - 48rpx);
		height: 68rpx;
		background-color: #7F7FE9;
		color: #fff;
		text-align: center;
		line-height: 68rpx;
		border-radius: 16rpx;
	}
}
</style>
